home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / xpkmaster / checksum.c < prev    next >
C/C++ Source or Header  |  1998-11-09  |  812b  |  43 lines

  1. #ifndef XPKMASTER_CHECKSUM_C
  2. #define XPKMASTER_CHECKSUM_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        checksum.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: checksum.c 1.3 (09.01.1998)
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    Simple checksum routines
  12.  
  13.  1.0   05.10.96 : first real version
  14.  1.1   30.01.97 : added new option to cchecksum, became necessary
  15.  1.2   31.01.97 : removed new option
  16.  1.3   09.01.98 : added XPK_ALLINONE
  17. */
  18.  
  19. #include <exec/types.h>
  20. #include "xpkmaster.h"
  21.  
  22. XPK_ALLINONE UBYTE hchecksum(STRPTR ptr, ULONG count)
  23. {
  24.   register UBYTE sum = 0;
  25.  
  26.   while(count-- > 0)
  27.     sum ^= *ptr++;
  28.  
  29.   return sum;
  30. }
  31.  
  32. XPK_ALLINONE UWORD cchecksum(ULONG *ptr, ULONG count)
  33. {
  34.   register ULONG sum = 0;
  35.  
  36.   while(count-- > 0)
  37.     sum ^= *ptr++;
  38.  
  39.   return (UWORD) (sum ^ (sum >> 16));
  40. }
  41.  
  42. #endif /* XPKMASTER_CHECKSUM_C */
  43.